package d0319;

import java.io.*;

public class FileDemo {
    public static void main(String[] args) {
     /*  File file=new File("src/com/d0319/test.txt");//相对路径
        File filel=new File("D:\\progream");    //绝对路径

        System.out.println("文件是否存在:"+filel.exists());
        System.out.println("是否为文件:"+filel.isFile());

        System.out.println("是否为目录:"+filel.isDirectory());
        System.out.println("文件名称" +filel.getName()  );
        System.out.println("文件绝对路径"+filel.getAbsolutePath());
        System.out.println("文件长度"+filel.length()); */
        File file = new File("D:/HelloWorld.txt");
        file.mkdir();
        File file1 = new File("D:/HelloWorld.txt/IOTest");
        System.out.println("是否为文件:" + file.isFile());

        System.out.println("是否为目录:" + file.isDirectory());
        try {
            System.out.println(file1.createNewFile() ? "创建成功" : "创建失败");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
